import { MessageBox } from 'element-ui'
const DEFAULT_TITLE = '提示信息'
const DEFAULT_OPTIONS = {
	closeOnClickModal: false,
	closeOnPressEscape: false,
	closeOnHashChange: false
}
export default {
	install (Vue) {
		const $Confirm = (options) => {
			const message = typeof options === 'string' ? options : options.message
			const title = typeof options === 'string' ? DEFAULT_TITLE : options.title || DEFAULT_TITLE
			const _options = typeof options === 'string' ? DEFAULT_OPTIONS : options
			return MessageBox.confirm(message, title, _options)
		}
		const $alert = function (options) {
			const message = typeof options === 'string' ? options : options.message
			const title = typeof options === 'string' ? DEFAULT_TITLE : options.message || DEFAULT_TITLE
			return MessageBox.alert(message, title, DEFAULT_OPTIONS)
		}
		Vue.prototype.$fxConfirm = $Confirm
		Vue.prototype.$fxAlert = $alert
	}
}
